/*
 * REFXMLSchemaDecl.h
 *
 *  Created on: Apr 1, 2013
 *      Author: Lucifer
 */

#ifndef	__BFX_REFXMLSCHEMADECLBASE_H__
#define	__BFX_REFXMLSCHEMADECLBASE_H__

#include "../core/REFXMLQualifiedName.h"
#include "XMLTokenizedType.h"

namespace BFX
{

typedef REFWrapper<Array<UniString> > REFStringArray;

//////////////////////////////////////////////////////////////////////////////

// NOTE: This is a abstract class
class REFXMLSchemaDecl : public REFObject
{
public:
	enum SchemaType
	{
		SchemaTypeNone,
		SchemaTypeDTD,
		SchemaTypeXDR,
		SchemaTypeXSD
	};

	enum Use
	{
		UseDefault,
		UseRequired,
		UseImplied,
		UseFixed,
		UseRequiredFixed
	};

public:
	REFXMLSchemaDecl();
	REFXMLSchemaDecl(REFXMLQualifiedName* pQName, const UniString& strPrefix);
	virtual ~REFXMLSchemaDecl();

	REFXMLQualifiedName* GetName() const;
	UniString GetPrefix() const;
	REFStringArray* GetValues() const;

	bool IsDeclaredInExternal() const;
	void SetDeclaredInExternal(bool bDeclaredInExternal);

	XMLTokenizedType GetDataType() const;
	void SetDataType(XMLTokenizedType dataType);

	Use GetPresence() const;
	void SetPresence(Use presence);

	UniString GetDefaultValueRaw() const;
	void SetDefaultValueRaw(const UniString& strDefVal);

private:
	REF<REFXMLQualifiedName>	m_pName;
	UniString			m_strPrefix;
	REF<REFStringArray>	m_pValues;

	XMLTokenizedType	m_dataType;

	bool				m_bDeclaredInExternal;
	Use					m_presence;	// the presence, such as fixed, implied, etc

	UniString			m_strDefaultValueRaw;	// default value in its original form
};

//////////////////////////////////////////////////////////////////////////////
inline REFXMLSchemaDecl::REFXMLSchemaDecl()
{
}
inline REFXMLSchemaDecl::REFXMLSchemaDecl(REFXMLQualifiedName* pName, const UniString& strPrefix)
{
	m_pName = pName;
	m_strPrefix = strPrefix;
	m_pValues = new REFStringArray();
	m_dataType = XMLTokenizedType_None;
	m_presence = UseDefault;
}
inline REFXMLSchemaDecl::~REFXMLSchemaDecl()
{
}

inline REFXMLQualifiedName* REFXMLSchemaDecl::GetName() const
{
	return m_pName;
}
inline UniString REFXMLSchemaDecl::GetPrefix() const
{
	return m_strPrefix;
}
inline REFStringArray* REFXMLSchemaDecl::GetValues() const
{
	return m_pValues;
}

inline bool REFXMLSchemaDecl::IsDeclaredInExternal() const
{
	return m_bDeclaredInExternal;
}
inline void REFXMLSchemaDecl::SetDeclaredInExternal(bool bDeclaredInExternal)
{
	m_bDeclaredInExternal = bDeclaredInExternal;
}

inline XMLTokenizedType REFXMLSchemaDecl::GetDataType() const
{
	return m_dataType;
}
inline void REFXMLSchemaDecl::SetDataType(XMLTokenizedType dataType)
{
	m_dataType = dataType;
}

inline REFXMLSchemaDecl::Use REFXMLSchemaDecl::GetPresence() const
{
	return m_presence;
}
inline void REFXMLSchemaDecl::SetPresence(Use presence)
{
	m_presence = presence;
}

inline UniString REFXMLSchemaDecl::GetDefaultValueRaw() const
{
	return m_strDefaultValueRaw;
}

inline void REFXMLSchemaDecl::SetDefaultValueRaw(const UniString& strDefVal)
{
	m_strDefaultValueRaw = strDefVal;
}

}	// namespace BFX

#endif	//	__BFX_REFXMLSCHEMADECLBASE_H__
